<template>
  <view>
      <view class="comment" v-for="(res) in commentsList" :key="res.id">
			<view class="left"><image :src="res.avatar" mode="aspectFill"></image></view>
			<view class="right">
				<view class="top">
					<view class="name">{{ res.createrName }}</view>
					<view class="like">
						<!-- <view class="num">{{ res.likeNum }}</view> -->
						<!-- <u-icon v-if="!res.isLike" name="thumb-up" :size="30" color="#9a9a9a" @click="getLike(index)"></u-icon>
						<u-icon v-if="res.isLike" name="thumb-up-fill" :size="30" @click="getLike(index)"></u-icon> -->
            <view v-if="!res.isLike" @click="reply">回复</view>
            <view v-if="res.isLike">删除</view>
					</view>
				</view>
        	<view class="date">
					{{ res.date }}
				</view>
				<view class="content">{{ res.contentText }}</view>
				<view class="reply-box">
					<view class="item" v-for="(item, index) in res.replyList" :key="index">
						<text class="username">{{ item.name }}</text>
            <text>：</text>
						<text class="text">{{ item.contentStr }}</text>
					</view>
					<view class="all-reply" @click="toAllReply" v-if="res.replyList != undefined">
						查看{{ res.allReply }}条回复
					</view>
				</view>
			
			</view>
		</view>

    <!-- 评论弹出层 -->
    <u-popup v-model="show" mode="bottom" border-radius="26" height="80%">
     <!-- 本人评论 -->
     <view class="popup-parcel">
      <view class="comments-header">
        <view>xx条回复</view>
        <commentsItem name="肖伟鸣" image="https://cdn.uviewui.com/uview/template/SmilingDog.jpg" time="12" content="你好啊我在加班啊哎难受"></commentsItem>
		    <!-- <view class="comments-detail">
			  <view class="my-self">
        <view class="user-comtent">
          <view class="user-avactar">
            <item-image
                img="https://cdn.uviewui.com/uview/template/SmilingDog.jpg"
                :width="100"
                :height="100"
                :radius="50"
              />
          </view>

          <view class="user-content-info">
            <view>你叫什么名字</view>
            <view>几个小时前</view>
            <view>评测内容评测内容评测内容评测内容评测内容评测内容评测内</view>
          </view>
        </view>
      </view>
		</view> -->

    </view>

     <!-- 回复标题 -->
          <view class="huifu">
            回复
          </view>
    <!-- 本人评论 end-->
    <view class="comments-items" v-for="(item, index) in commentList" :key="index">
      <commentsItem :image="item.url" :name="item.name" :content="item.contentText" :time="item.date"></commentsItem>
    </view>
    <comment-inputs :focus="focus"></comment-inputs>
    </view>
	</u-popup>
  </view>
</template>

<script>
import commentsItem from '../../acomponents/commentsItem.vue';
import commentInputs from '../../acomponents/commentInputs.vue';
export default {
  name: 'comments',
  props: {
    commentsList: {
      type: Array
    }
  },
  components: {
    commentInputs,commentsItem
  },
  data () {
    return {
      
      show:false,
      focus: false,
      
    }
  },
  created () {
     
  },
  
  methods: {
    // 回复
    reply(){
      this.focus = !this.focus
      this.$emit("onFocus",this.focus)
    },
    // 查看所有评论
    toAllReply(){
      this.show = true
      console.log(123,'你好啊');
    },
    // 评论列表
  }
}
</script>

<style lang="scss" scoped>
  .comment {
	display: flex;
	padding: 28rpx;
	.left {
		image {
			width: 100rpx;
			height: 100rpx;
			border-radius: 50%;
			background-color: #f2f2f2;
		}
	}
	.right {
		flex: 1;
		padding-left: 20rpx;
		font-size: 30rpx;
		.top {
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-bottom: 10rpx;
			.name {
				color: #333333;
        font-size: 30rpx;
			}
			.like {
				display: flex;
				align-items: center;
        margin-right: 10rpx;
				color: #4D4D4D;
				font-size: 26rpx;
			}
		}
		.content {
      font-size: 24rpx;
			margin-bottom: 10rpx;
		}
		.reply-box {
			background-color:#F0F1F5;
			border-radius: 12rpx;
      font-size: 24rpx;
      color: #4D4D4D;
			.item {
				padding: 12rpx;
        padding-bottom: 0;
				// border-bottom: solid 2rpx $u-border-color;
				.username {
					font-size: 30rpx;
					color: #333333;
				}
			}
			.all-reply {
				padding: 20rpx;
				display: flex;
				color: #765CFE;
				align-items: center;
        font-size: 30rpx;
				.more {
					margin-left: 6rpx;
				}
			}
		}
		// .bottom {
		// 	margin-top: 20rpx;
		// 	display: flex;
		// 	font-size: 24rpx;
		// 	color: #9a9a9a;
		// 	.reply {
		// 		color: #5677fc;
		// 		margin-left: 10rpx;
		// 	}
		// }
	}
}

.date {
  margin-bottom: 10rpx;
  font-size: 24rpx;
  color: #4D4D4D;
}

.popup-parcel {
  padding-bottom: 150rpx;
}

.comments-header {
  border-bottom: 1rpx #f0f1f5 solid;
  padding: 30rpx 30rpx 0 30rpx
}

.comments-detail {
  padding: 30rpx 0;
}

.user-comtent {
  display: flex;
}

.user-avactar {
  align-items: flex-start;
  margin-right: 20rpx;
}

.user-content-info {
  display: flex;
  flex-direction: column;
}

.huifu {
  color: #000;
  font-size: 28rpx;
  margin: 20rpx 0 30rpx 30rpx;
}

.comments-items {
  padding: 0 30rpx 0rpx 30rpx;
}
</style>
